home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr53 / pctv4n_1.zip / DBDESCQE.C < prev    next >
Text File  |  1993-06-10  |  1KB  |  59 lines

  1. /***************************************************
  2. * FUNCTION NAME: dbDescribe for Q+E Database Library
  3. *
  4. * SYNOPSIS:
  5. *     get column description info
  6. ***************************************************/
  7. int dbDescribe(int ColumnPos,
  8.            struct ColumnDesc *col,
  9.            REQUEST rq)
  10. {
  11. char    far *name;
  12. int       Status;
  13.  
  14.     col->namelen = NAMELENGTH;
  15.     col->data_type = 0;
  16.     col->length = 0;
  17.     col->scale = 0;
  18.     strcpy(col->fldname,"   ");
  19.  
  20.      /* get the column name, type, width, etc. */
  21.     name = qeColName ( rq->hstmt, ColumnPos );
  22.     Status = qeErr();
  23.     if (Status == SQL_SUCCESS)
  24.         {
  25.         strcpy(col->fldname,name);
  26.         }
  27.     else return Status;
  28.  
  29.               /* get the column type */
  30.     col->data_type = qeColType ( rq->hstmt, 
  31.                   ColumnPos );
  32.     Status = qeErr();
  33.     if (Status != SQL_SUCCESS)
  34.         return Status;
  35.  
  36.               /* get the column width */
  37.     col->length = qeColWidth ( rq->hstmt,
  38.                   ColumnPos );
  39.     Status = qeErr();
  40.     if (Status == SQL_SUCCESS)
  41.         {
  42.         if (col->data_type == CHARACTER)
  43.             --col->length;
  44.         }
  45.     else return Status;
  46.  
  47.     if (col->data_type == DECIMAL)
  48.         {
  49.         col->scale = qeColScale ( rq->hstmt,
  50.                     ColumnPos );
  51.         Status = qeErr();
  52.         if (Status != SQL_SUCCESS)
  53.             return Status;
  54.         }
  55.  
  56.     return SQL_SUCCESS;
  57. }
  58.  
  59.